home *** CD-ROM | disk | FTP | other *** search
/ Enigma Amiga Life 109 / EnigmaAmiga109CD.iso / dalla rivista / amiga.free / sorgenti vari / wolf3dmacsource.sit / Wolf3DMacSource / HideMenuBar.c < prev    next >
C/C++ Source or Header  |  2000-01-21  |  3KB  |  98 lines

  1. #include "hidemenubar.h"
  2.                                             
  3. static Boolean MenuBarHidden = FALSE;        /* Current state of the menu bar. */
  4. static Rect OldeMBarRect;        /* Saves rectangle enclosing real menu bar. */
  5. static RgnHandle OldeGrayRgn;    /* Saves the region defining the desktop */
  6. static short OldMBarHeight;        /* Previous menu bar height */
  7. extern GDHandle gMainGDH;
  8.  
  9. /********************************
  10.  
  11.     Hide the menu bar (If visible)
  12.  
  13. ********************************/
  14.  
  15. void HideMenuBar(void)
  16. {
  17.     RgnHandle menuRgn;
  18.     WindowPeek theWindow;
  19.     GDHandle TempHand;
  20.     
  21.     TempHand = GetMainDevice();
  22.     if (TempHand!=gMainGDH) {    /* Main graphics handle */
  23.         return;
  24.     }                
  25.     if (!MenuBarHidden) {        /* Already hidden? */
  26.         OldMBarHeight = LMGetMBarHeight();    /* Get the height in pixels */
  27.         OldeGrayRgn = NewRgn();        /* Make a new region */
  28.         CopyRgn(GetGrayRgn(), OldeGrayRgn);    /* Copy the background region */
  29.         OldeMBarRect = qd.screenBits.bounds;    /* Make a region from the rect or the monitor width */
  30.         OldeMBarRect.bottom = OldeMBarRect.top + OldMBarHeight;    /* Top to bottom of menu */
  31.         menuRgn = NewRgn();            /* Convert to region */
  32.         RectRgn(menuRgn, &OldeMBarRect);
  33.         
  34.         UnionRgn(GetGrayRgn(), menuRgn, GetGrayRgn());    /* Add the menu area to background */
  35.         theWindow = (WindowPeek)FrontWindow();
  36.         PaintOne((WindowPtr)theWindow, menuRgn);            /* Redraw the front window */
  37.         PaintBehind((WindowPtr)theWindow, menuRgn);        /* Redraw all other windows */
  38.         CalcVis((WindowPtr)theWindow);                        /* Resize the visible region */
  39.         CalcVisBehind((WindowPtr)theWindow, menuRgn);        /* Resize the visible regions for all others */
  40.         DisposeRgn(menuRgn);                /* Release the menu region */
  41.         MenuBarHidden = TRUE;                /* It is now hidden */
  42.         ZapMHeight();                        /* Zap the height */
  43.     }
  44. }
  45.  
  46. /********************************
  47.  
  48.     Show the menu bar (If hidden)
  49.  
  50. ********************************/
  51.  
  52. void ShowMenuBar(void)
  53. {
  54.     WindowPeek theWindow;
  55.     
  56.     if (MenuBarHidden) {        /* Hidden? */
  57.         FixMHeight();
  58.         MenuBarHidden = FALSE;        /* The bar is here */
  59.         CopyRgn(OldeGrayRgn, GetGrayRgn());    /* Get the region */
  60.         RectRgn(OldeGrayRgn, &OldeMBarRect);    /* Convert menu rect to region */
  61.         theWindow = (WindowPeek)FrontWindow();    /* Get the front window */
  62.         CalcVis((WindowPtr)theWindow);                /* Reset the visible region */
  63.         CalcVisBehind((WindowPtr)theWindow,OldeGrayRgn);    /* Remove the menu bar from windows */
  64.         DisposeRgn(OldeGrayRgn);        /* Bye bye region */
  65.         OldeGrayRgn = 0;            /* Zap the handle */
  66.         HiliteMenu(0);                /* Don't hilite any menu options */
  67.         DrawMenuBar();                /* Redraw the menu bar */
  68.     }
  69. }
  70.  
  71. /********************************
  72.  
  73.     Restore the menu bar height so that
  74.     the OS can handle menu bar events
  75.  
  76. ********************************/
  77.  
  78. void FixMHeight(void)
  79. {
  80.     if (MenuBarHidden) {        /* Hidden? */
  81.         LMSetMBarHeight(OldMBarHeight);        /* Reset the height */
  82.     }
  83. }
  84.  
  85. /********************************
  86.  
  87.     Zap the menu bar height so that things
  88.     like MenuClock won't draw
  89.  
  90. ********************************/
  91.  
  92. void ZapMHeight(void)
  93. {
  94.     if (MenuBarHidden) {        /* Hidden? */
  95.         LMSetMBarHeight(0);        /* Zap the height */
  96.     }
  97. }
  98.